﻿using System.Web;
using System.IO;
using System.Text;
using System.Web.Configuration;

namespace AjaxUploadServer
{
	public class ServerConfigureItem
	{
		[Newtonsoft.Json.JsonProperty("CMD")]
		public JsonData<ushort> Commands;
		[Newtonsoft.Json.JsonProperty("CONFIG")]
		public JsonData<object> Configure;
		[Newtonsoft.Json.JsonProperty("HEADERS")]
		public JsonData<string> Headers;
	}
	public class ServerConfigure : ServerContext<ServerConfigure>
	{
		public ServerConfigure(string filename, HttpContextBase context): base(filename, context)
		{
			this.Load();
		}
		public ServerConfigure(string filename, IServerManager server) : base(filename, server)
		{
			this.Load();
		}
		private ServerConfigureItem _items;

		public JsonData<ushort> Commands
		{
			get { return _items.Commands; }
		}
		public JsonData<object> Configure
		{
			get { return _items.Configure; }
		}
		public JsonData<string> Headers
		{
			get { return _items.Headers; }
		}

		public sealed override void Load()
		{
			var json = this.LoadJson();
			var settings = new Newtonsoft.Json.JsonSerializerSettings();
			_items = Newtonsoft.Json.JsonConvert.DeserializeObject<ServerConfigureItem>(json, settings);
		}
	}
}